package com.hl.sfzy.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hl.sfzy.constant.CommonConstant;
import com.hl.sfzy.entity.Interest;
import com.hl.sfzy.entity.User;
import com.hl.sfzy.mapper.InterestMapper;
import com.hl.sfzy.mapper.UserMapper;
import com.hl.sfzy.service.InterestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @ClassName InterestServiceImpl
 * @Description TODO
 * @Author Jerry
 * @Date 2024年01月15日 8:37
 * @Version 1.0
 */
@Service("InterestService")
public class InterestServiceImpl implements InterestService {
    @Autowired
    private InterestMapper InterestMapper;
    @Override
    public void add(Interest entity) throws Exception {
        InterestMapper.insert(entity);
    }

    @Override
    public void edit(Interest entity) {
InterestMapper.update(entity);
    }

    @Override
    public void remove(Integer id) {
InterestMapper.delete(id);
    }

    @Override
    public void removeBatch(Integer[] ids) {
InterestMapper.deleteBatch(ids);
    }

    @Override
    public List<Interest> find(Interest entity) {
        return InterestMapper.select(entity);
    }

    @Override
    public Map<String, Object> findPage(Integer pageNum, Integer pageSize, Interest entity) {
        PageHelper.startPage(pageNum, pageSize);

        List<Interest> list = InterestMapper.select(entity); // 当前页数据

        PageInfo<Interest> pageInfo = new PageInfo<>(list); // 分页信息对象
        Map<String, Object> pageMap = new HashMap<>();
        pageMap.put(CommonConstant.PAGE_LIST, list);
        pageMap.put(CommonConstant.PAGE_TOTAL, pageInfo.getTotal());

        return pageMap;
    }

    @Override
    public Interest findById(Integer id) {
        return null;
    }
}
